/*
 * Mutex.cpp
 *
 *  Created on: 14.12.2012
 *      Author: zheka
 */

#include "Mutex.hpp"

Mutex::Mutex() {
	pthread_mutexattr_t attr;
	pthread_mutexattr_init(&attr);
	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
	pthread_mutex_init(&mutex, &attr);
	pthread_mutexattr_destroy(&attr);
//	pthread_mutex_init(&mutex, NULL);
}
Mutex::~Mutex() {
	pthread_mutex_destroy(&mutex);
}
void Mutex::lock() {
	pthread_mutex_lock(&mutex);
}
void Mutex::unlock() {
	pthread_mutex_unlock(&mutex);
}

pthread_mutex_t * Mutex::getMutex() {
	return &mutex;
}
